<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'basicdata.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item><a routerLink="/pages/purchase/purchase-order">生产质检单</a></d-breadcrumb-item>
      <d-breadcrumb-item>新建巡检单</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="da-form-container">
      <div class="card">
        <form dForm ngForm [layout]="layoutDirection" [labelSize]="'sm'" [labelAlign]="'end'" class="mt-5"
          (dSubmit)="submit($event)">
          <div class="form-header">
            <p class="form-title">新建巡检单</p>
            <div class="form-head-btnGroup">
              <d-form-operation class="form-header-btn">
                <d-button class="me-3" bsStyle="primary" (btnClick)="selectOrder()">选择工单工序</d-button>
                <d-button class="me-3" bsStyle="primary" dFormSubmit>确定</d-button>
                <d-button bsStyle="common" (btnClick)="cancel()">取消</d-button>
              </d-form-operation>
            </div>
          </div>
          <div class="form-body">
            <div>
              <h4>基础信息</h4>
            </div>
            <div class="grid mt-3">
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>质检单号</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="质检单号"
                      [(ngModel)]="productionInspectionOrder.productionInspectionOrderNum"
                      [dValidateRules]="productionInspectionOrderRules.productionInspectionOrderNum">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>工单号</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="工单号" [(ngModel)]="productionInspectionOrder.jobNum"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.jobNum">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>工序编码</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="工序编码" [(ngModel)]="productionInspectionOrder.processNum"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.processNum">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>工序名称</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="工序名称" [(ngModel)]="productionInspectionOrder.procssName"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.procssName">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label">物料编码</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="物料编码" [(ngModel)]="productionInspectionOrder.productNum"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.productNum">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label">物料名称</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="物料名称" [(ngModel)]="productionInspectionOrder.productName"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.productName">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label">规格型号</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="规格型号" [(ngModel)]="productionInspectionOrder.partType"
                      [disabled]="true" [dValidateRules]="productionInspectionOrderRules.partType">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label">单位</span>
                  </d-form-label>
                  <d-form-control>
                    <input type="text" dTextInput name="单位" [disabled]="true"
                      [(ngModel)]="productionInspectionOrder.uom" [dValidateRules]="productionInspectionOrderRules.uom">
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>质检数量</span>
                  </d-form-label>
                  <d-form-control>
                    <d-input-number [(ngModel)]="productionInspectionOrder.pendingInspectionQuantity"
                      class="input-number" [min]="0" name="质检数量"
                      [dValidateRules]="productionInspectionOrderRules.productionInspectionOrder">
                    </d-input-number>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>合格数量</span>
                  </d-form-label>
                  <d-form-control>
                    <d-input-number [(ngModel)]="productionInspectionOrder.qualifiedAmount" class="input-number"
                      [min]="0" name="合格数量">
                    </d-input-number>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>不合格数量</span>
                  </d-form-label>
                  <d-form-control>
                    <d-input-number [(ngModel)]="productionInspectionOrder.unqualifiedAmount" class="input-number"
                      [min]="0" name="不合格数量">
                    </d-input-number>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>报废数量</span>
                  </d-form-label>
                  <d-form-control>
                    <d-input-number [(ngModel)]="productionInspectionOrder.scrapAmount" class="input-number" [min]="0"
                      name="报废数量">
                    </d-input-number>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label"><span class="Required">*</span>是否合格</span>
                  </d-form-label>
                  <d-form-control>
                    <d-radio-group [name]="'item-group'" [values]="items" class="input-number" [direction]="'row'"
                      [(ngModel)]="item" (change)="valueChange($event)">
                    </d-radio-group>
                  </d-form-control>
                </d-form-item>
              </div>
              <div class="u-1">
                <d-form-item>
                  <d-form-label>
                    <span class="label">备注</span>
                  </d-form-label>
                  <d-form-control class="textarea">
                    <textarea dTextarea name="备注" [(ngModel)]="productionInspectionOrder.remarks"></textarea>
                  </d-form-control>
                </d-form-item>
              </div>
            </div>
            <div>
              <h4>质检项目</h4>
            </div>
            <div class="table">
              <d-data-table [dataSource]="productionInspectionOrder.inspectionProjects" [lazy]="true"
                [scrollable]="true" [fixHeader]="true" [scrollable]="true" [resizeable]="true"
                [tableWidthConfig]="tableWidthConfig">
                <thead dTableHead>
                  <tr dTableRow>
                    <th dHeadCell [fixedLeft]="'0px'">
                      <span>操作</span>
                    </th>
                    <th dHeadCell>
                      <span><span class="Required">*</span>质检项</span>
                    </th>
                    <th dHeadCell>
                      <span>质检项描述</span>
                    </th>
                    <th dHeadCell>
                      <span>质检单位</span>
                    </th>
                    <th dHeadCell>
                      <span>附件</span>
                    </th>
                  </tr>
                </thead>
                <tbody dTableBody>
                  <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex">
                    <tr dTableRow>
                      <td dTableCell [fixedLeft]="'0px'">
                        <span (click)="addRow()"><i class="icon-code-editor-add add"></i></span>
                        <span class="ms-3" (click)="deleteRow(rowIndex)"><i class="icon-code-editor-less minus"
                            style="font-size: 16px;"></i></span>
                      </td>
                      <td dTableCell>
                        <input type="text" dTextInput [ngModelOptions]="{standalone: true}"
                          [(ngModel)]="rowItem.inspectionProjectName" (click)="selectItem(rowItem)">
                      </td>
                      <td dTableCell>
                        <span dTooltip
                          [content]="rowItem.inspectionProjectDescription">{{rowItem.inspectionProjectDescription}}</span>
                      </td>
                      <td dTableCell>
                        <span dTooltip
                          [content]="rowItem.inspectionProjectUnit">{{rowItem.inspectionProjectUnit}}</span>
                      </td>
                      <td dTableCell>
                        <span (click)="fujianItem(rowItem)" dTooltip>
                          <a dStyle="primary">附件</a>
                        </span>
                      </td>
                    </tr>
                  </ng-template>
                </tbody>
              </d-data-table>
            </div>
            <div class="grid mt-3">
              <div class="u-1-3">
                <d-form-item>
                  <d-form-label>
                    <span class="label">附件</span>
                  </d-form-label>
                  <d-form-control>
                    <d-badge [count]="fujianNumber">
                      <d-button bsStyle="common" (btnClick)="fujian()"><i
                          class="icon icon-upload me-2"></i><span>附件</span></d-button>
                    </d-badge>
                  </d-form-control>
                </d-form-item>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
